<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组件嵌套</title>
    <script src="../../js/vue.js"></script>
</head>
<body>
    <div id="root"> </div>
</body>

<script type="text/javascript">
    // 简写形式
    const hello = {
        template: `
            <div>
              <h2>{{greet}}</h2>
            </div>
        `,
        data() {
            return {
                greet: 'Hello Vue'
            }
        }
    }

    const school = {
        template: `
            <div>
              <h2>学校名称：{{name}}，地址：{{address}}</h2>
            </div>
        `,
        data() {
            return {
                name: '斯坦福大学',
                address: '地球'
            }
        }
    }

    const global = {
        template: `
            <div>
              <hello></hello>
              <school></school>
            </div>
        `,
        data() {
            return {
                whole: '我就是全局组件'
            }
        },
        components: {
            school,
            hello
        }
    }

    new Vue({
        template: `
            <div>
              <global></global>
            </div>
        `,
        el: '#root',
        data: {
            msg: '下面就是非单组件'
        },
        components: {
            global
        }
    })
</script>
</html>